import * as constants from '../Constants'
import { get, ONE_PHASE_API } from '../../service/api'

export interface GetOrderList {
  type: constants.GetOrderList
  payload: Promise<any>
}

export interface GetOrderList_PENDING {
  type: constants.GetOrderList_PENDING
  payload: Promise<any>
}

export interface GetOrderList_FULFILLED {
  type: constants.GetOrderList_FULFILLED
  payload: any
}

export interface GetOrderList_PAGE {
  type: constants.GetOrderList_PAGE
  payload: any
}

export interface RECORD_Order_ID {
  type: constants.RECORD_Order_ID
  payload: any
}

export interface GetOrderDetailList {
  type: constants.GetOrderDetailList
  payload: Promise<any>
}

export interface GetOrderDetailList_PENDING {
  type: constants.GetOrderDetailList_PENDING
  payload: Promise<any>
}

export interface GetOrderDetailList_FULFILLED {
  type: constants.GetOrderDetailList_FULFILLED
  payload: any
}

export interface GetOrderDetailList_PAGE {
  type: constants.GetOrderDetailList_PAGE
  payload: any
}

export type OrderAction = GetOrderList | 
  GetOrderList_FULFILLED | 
  GetOrderList_PENDING | 
  GetOrderList_PAGE |
  RECORD_Order_ID |
  GetOrderDetailList |
  GetOrderDetailList_FULFILLED | 
  GetOrderDetailList_PENDING | 
  GetOrderDetailList_PAGE

export function getOrderList(param: any): GetOrderList {
  return {
    type: constants.GetOrderList,
    payload: get(ONE_PHASE_API, param)
  }
}
export function page(page: any): GetOrderList_PAGE {
  return {
    type: constants.GetOrderList_PAGE,
    payload: page
  }
}
export function recordOrderId(param: any): RECORD_Order_ID {
  return {
    type: constants.RECORD_Order_ID,
    payload: param
  }
}
export function getOrderDetailList(param: any): GetOrderDetailList {
  return {
    type: constants.GetOrderDetailList,
    payload: get(ONE_PHASE_API, param)
  }
}
export function pageDetail(page: any): GetOrderDetailList_PAGE {
  return {
    type: constants.GetOrderDetailList_PAGE,
    payload: page
  }
}